package com.cn.wanxi.util.utils;

import com.cn.wanxi.util.model.SchoolAboutModel;
import com.cn.wanxi.util.model.SchoolCurriculumModel;
import com.cn.wanxi.util.model.SchoolServerModel;

import java.util.ArrayList;
import java.util.List;

public class SchoolCurriculumUtile {
    FileUtile fileUtile=new FileUtile();
    public List<SchoolCurriculumModel> readSchoolCurriculum(){
        List<SchoolCurriculumModel> schoolCurriculumList =new ArrayList<>();
        String curriculum =fileUtile.readFileToString("SchoolCurriculumFile.txt");
        String[] curriculums = curriculum.split(";");
        for (int i=0;i<curriculums.length;i++){
            String item = curriculums[i];
            String[] info = item.split(",");
            SchoolCurriculumModel schoolCurriculumModel = new SchoolCurriculumModel(info[0].trim(),info[1].trim());
            schoolCurriculumList.add(schoolCurriculumModel);
        }
        return schoolCurriculumList;
    }

//    服务介绍
    public List<SchoolServerModel> readSchoolServer(){
        List<SchoolServerModel> schoolServerModelList =new ArrayList<>();
        String server = fileUtile.readFileToString("SchoolServerFile.txt");
        String[] servers = server.split(";");
        for (int i=0;i<servers.length;i++){
            String item = servers[i];
            String[] info = item.split(",");
            SchoolServerModel schoolServerModel = new SchoolServerModel(info[0].trim(),info[1].trim(),info[2].trim(),info[3].trim(),info[4].trim(),info[5].trim());
            schoolServerModelList.add(schoolServerModel);
        }
        return schoolServerModelList;
    }

    public List<SchoolAboutModel> readSchoolAbout(){
        List<SchoolAboutModel> schoolAboutList =new ArrayList<>();
        String about =fileUtile.readFileToString("SchoolAboutFile.txt");
        String[] abouts = about.split(";");
        for (int i=0;i<abouts.length;i++){
            String item = abouts[i];
            String[] info = item.split(",");
            SchoolAboutModel schoolAboutModel = new SchoolAboutModel(info[0].trim(),info[1].trim(),info[2].trim(),info[3].trim());
            schoolAboutList.add(schoolAboutModel);
        }
        return schoolAboutList;
    }
}
